#include "com_voe_AudioDeviceModule.h"
#include "jni_api.h"
#include "audio_device.h"
#include "audio_device_defines.h"
#include "OutputParam.h"
#include "AudioDeviceObserverImpl.h"
#include "AudioTransportImpl.h"

static AudioTransportImpl _AudioTransport;
static AudioDeviceObserverImpl _AudioDeviceObserver;

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    CreateAudioDeviceModule
 * Signature: (II)J
 */
JNIEXPORT jlong JNICALL Java_com_voe_AudioDeviceModule_CreateAudioDeviceModule
	(JNIEnv * env, jclass cls, jint id, jint audioLayer)
{
	return (jlong)webrtc::CreateAudioDeviceModule(id, (webrtc::AudioDeviceModule::AudioLayer)audioLayer);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    ActiveAudioLayer
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_ActiveAudioLayer
  (JNIEnv * env, jclass cls, jlong p, jobject output)
{
	jint result = 0;
	JniOutputBuilder job(env);
	if(p)
	{
		webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
		webrtc::AudioDeviceModule::AudioLayer audioLayer;
		result = pDeviceModule->ActiveAudioLayer(&audioLayer);
		OutputParam param(env, output);
		param.setArray(job.add(audioLayer).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    LastError
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_LastError
  (JNIEnv * env, jclass cls, jlong p)
{
	jint result = 0;
	if(p)
	{
		webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
		result = (jint)pDeviceModule->LastError();
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RegisterEventObserver
 * Signature: (JLcom/voe/callback/AudioDeviceObserver;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_RegisterEventObserver
  (JNIEnv * env, jclass cls, jlong p, jobject observer)
{
	jint result = 0;
	if(p)
	{
		webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
		if(observer)
		{
			if(_AudioDeviceObserver.set(env, observer))
			{
				result = (jint)pDeviceModule->RegisterEventObserver(&_AudioDeviceObserver);
			}
			else
			{
				result = -2;
			}
		}
		else
		{
			result = (jint)pDeviceModule->RegisterEventObserver(0);
			if(result == 0) _AudioDeviceObserver.unset(env);
		}
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RegisterAudioCallback
 * Signature: (JLcom/voe/callback/AudioTransport;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_RegisterAudioCallback
  (JNIEnv * env, jclass cls, jlong p, jobject audioCallback)
{
	jint result = 0;
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	if(audioCallback)
	{
		if(_AudioTransport.set(env, audioCallback))
		{
			result = (jint)pDeviceModule->RegisterAudioCallback(&_AudioTransport);
		}
		else
		{
			result = JCB_Err_Set;
		}
	}
	else
	{
		result = (jint)pDeviceModule->RegisterAudioCallback(0);
		if(result == 0) _AudioTransport.unset(env);
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    Init
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_Init
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->Init();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    Terminate
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_Terminate
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->Terminate();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    Initialized
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_Initialized
	(JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->Initialized();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    PlayoutDevices
 * Signature: (J)S
 */
JNIEXPORT jshort JNICALL Java_com_voe_AudioDeviceModule_PlayoutDevices
	(JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jshort)pDeviceModule->PlayoutDevices();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RecordingDevices
 * Signature: (J)S
 */
JNIEXPORT jshort JNICALL Java_com_voe_AudioDeviceModule_RecordingDevices
	(JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jshort)pDeviceModule->RecordingDevices();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    PlayoutDeviceName
 * Signature: (JSLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_PlayoutDeviceName
  (JNIEnv * env, jclass cls, jlong p, jshort index, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	char name[webrtc::kAdmMaxDeviceNameSize] = {0};
	char guid[webrtc::kAdmMaxGuidSize] = {0};
	jint result = (jint)pDeviceModule->PlayoutDeviceName(index, name, guid);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(std::string(name)).add(std::string(guid)).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RecordingDeviceName
 * Signature: (JSLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_RecordingDeviceName
  (JNIEnv * env, jclass cls, jlong p, jshort index, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	char name[webrtc::kAdmMaxDeviceNameSize] = {0};
	char guid[webrtc::kAdmMaxGuidSize] = {0};
	jint result = (jint)pDeviceModule->RecordingDeviceName(index, name, guid);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(std::string(name)).add(std::string(guid)).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetPlayoutDevice
 * Signature: (JS)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetPlayoutDevice
	(JNIEnv * env, jclass cls, jlong p, jshort index)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetPlayoutDevice(index);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetPlayoutDevice2
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetPlayoutDevice2
	(JNIEnv * env, jclass cls, jlong p, jint device)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetPlayoutDevice((webrtc::AudioDeviceModule::WindowsDeviceType)device);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetRecordingDevice
 * Signature: (JS)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetRecordingDevice
	(JNIEnv * env, jclass cls, jlong p, jshort index)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetRecordingDevice(index);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetRecordingDevice2
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetRecordingDevice2
	(JNIEnv * env, jclass cls, jlong p, jint device)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetRecordingDevice((webrtc::AudioDeviceModule::WindowsDeviceType)device);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    PlayoutIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_PlayoutIsAvailable
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->PlayoutIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    InitPlayout
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_InitPlayout
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->InitPlayout();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    PlayoutIsInitialized
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_PlayoutIsInitialized
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->PlayoutIsInitialized();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RecordingIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_RecordingIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->RecordingIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    InitRecording
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_InitRecording
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->InitRecording();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RecordingIsInitialized
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_RecordingIsInitialized
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->RecordingIsInitialized();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StartPlayout
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StartPlayout
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StartPlayout();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StopPlayout
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StopPlayout
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StopPlayout();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    Playing
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_Playing
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->Playing();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StartRecording
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StartRecording
	(JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StartRecording();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StopRecording
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StopRecording
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StopRecording();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    Recording
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_Recording
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->Recording();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetAGC
 * Signature: (JZ)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetAGC
  (JNIEnv * env, jclass cls, jlong p, jboolean enable)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetAGC(enable != 0);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    AGC
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_AGC
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->AGC();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetWaveOutVolume
 * Signature: (JSS)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetWaveOutVolume
  (JNIEnv * env, jclass cls, jlong p, jshort volumeLeft, jshort volumeRight)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetWaveOutVolume(volumeLeft, volumeRight);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    WaveOutVolume
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_WaveOutVolume
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint16_t volumeLeft = 0, volumeRight = 0;
	jint result = (jint)pDeviceModule->WaveOutVolume(&volumeLeft, &volumeRight);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)volumeLeft).add((int)volumeRight).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SpeakerIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SpeakerIsAvailable
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->SpeakerIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    InitSpeaker
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_InitSpeaker
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->InitSpeaker();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SpeakerIsInitialized
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_SpeakerIsInitialized
	(JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->SpeakerIsInitialized();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->MicrophoneIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    InitMicrophone
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_InitMicrophone
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->InitMicrophone();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneIsInitialized
 * Signature: (J)Z
 */
JNIEXPORT jboolean JNICALL Java_com_voe_AudioDeviceModule_MicrophoneIsInitialized
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jboolean)pDeviceModule->MicrophoneIsInitialized();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SpeakerVolumeIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SpeakerVolumeIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->SpeakerVolumeIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetSpeakerVolume
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetSpeakerVolume
  (JNIEnv * env, jclass cls, jlong p, jint volume)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetSpeakerVolume(volume);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SpeakerVolume
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SpeakerVolume
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t volume = 0;
	jint result = (jint)pDeviceModule->SpeakerVolume(&volume);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)volume).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MaxSpeakerVolume
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MaxSpeakerVolume
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t maxVolume = 0;
	jint result = (jint)pDeviceModule->MaxSpeakerVolume(&maxVolume);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)maxVolume).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MinSpeakerVolume
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MinSpeakerVolume
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t minVolume = 0;
	jint result = (jint)pDeviceModule->MinSpeakerVolume(&minVolume);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)minVolume).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SpeakerVolumeStepSize
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SpeakerVolumeStepSize
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint16_t stepSize = 0;
	jint result = (jint)pDeviceModule->SpeakerVolumeStepSize(&stepSize);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)stepSize).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneVolumeIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneVolumeIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->MicrophoneVolumeIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetMicrophoneVolume
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetMicrophoneVolume
	(JNIEnv * env, jclass cls, jlong p, jint volume)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetMicrophoneVolume(volume);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneVolume
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneVolume
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t volume = 0;
	jint result = (jint)pDeviceModule->MicrophoneVolume(&volume);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)volume).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MaxMicrophoneVolume
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MaxMicrophoneVolume
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t maxVolume = 0;
	jint result = (jint)pDeviceModule->MaxMicrophoneVolume(&maxVolume);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)maxVolume).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MinMicrophoneVolume
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MinMicrophoneVolume
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t minVolume = 0;
	jint result = (jint)pDeviceModule->MinMicrophoneVolume(&minVolume);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)minVolume).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneVolumeStepSize
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneVolumeStepSize
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint16_t stepSize = 0;
	jint result = (jint)pDeviceModule->MicrophoneVolumeStepSize(&stepSize);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)stepSize).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SpeakerMuteIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SpeakerMuteIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->SpeakerMuteIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetSpeakerMute
 * Signature: (JZ)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetSpeakerMute
  (JNIEnv * env, jclass cls, jlong p, jboolean enable)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetSpeakerMute(enable != 0);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SpeakerMute
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SpeakerMute
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool enabled = false;
	jint result = (jint)pDeviceModule->SpeakerMute(&enabled);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(enabled).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneMuteIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneMuteIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->MicrophoneMuteIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetMicrophoneMute
 * Signature: (JZ)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetMicrophoneMute
	(JNIEnv * env, jclass cls, jlong p, jboolean enable)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetMicrophoneMute(enable != 0);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneMute
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneMute
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool enabled = false;
	jint result = (jint)pDeviceModule->MicrophoneMute(&enabled);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(enabled).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneBoostIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneBoostIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->MicrophoneBoostIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetMicrophoneBoost
 * Signature: (JZ)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetMicrophoneBoost
	(JNIEnv * env, jclass cls, jlong p, jboolean enable)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetMicrophoneBoost(enable != 0);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    MicrophoneBoost
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_MicrophoneBoost
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool enabled = false;
	jint result = (jint)pDeviceModule->MicrophoneBoost(&enabled);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(enabled).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StereoPlayoutIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StereoPlayoutIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->StereoPlayoutIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetStereoPlayout
 * Signature: (JZ)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetStereoPlayout
	(JNIEnv * env, jclass cls, jlong p, jboolean enable)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetStereoPlayout(enable != 0);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StereoPlayout
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StereoPlayout
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool enabled = false;
	jint result = (jint)pDeviceModule->StereoPlayout(&enabled);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(enabled).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StereoRecordingIsAvailable
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StereoRecordingIsAvailable
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool available = false;
	jint result = (jint)pDeviceModule->StereoRecordingIsAvailable(&available);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(available).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetStereoRecording
 * Signature: (JZ)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetStereoRecording
	(JNIEnv * env, jclass cls, jlong p, jboolean enable)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetStereoRecording(enable != 0);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StereoRecording
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StereoRecording
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool enabled = false;
	jint result = (jint)pDeviceModule->StereoRecording(&enabled);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(enabled).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetRecordingChannel
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetRecordingChannel
  (JNIEnv * env, jclass cls, jlong p, jint channel)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetRecordingChannel((webrtc::AudioDeviceModule::ChannelType)channel);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RecordingChannel
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_RecordingChannel
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	webrtc::AudioDeviceModule::ChannelType channel;
	jint result = (jint)pDeviceModule->RecordingChannel(&channel);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)channel).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetPlayoutBuffer
 * Signature: (JIS)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetPlayoutBuffer
  (JNIEnv * env, jclass cls, jlong p, jint type, jshort sizeMS)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetPlayoutBuffer((webrtc::AudioDeviceModule::BufferType)type, (uint16_t)sizeMS);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    PlayoutBuffer
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_PlayoutBuffer
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	webrtc::AudioDeviceModule::BufferType type;
	uint16_t sizeMS;
	jint result = (jint)pDeviceModule->PlayoutBuffer(&type, &sizeMS);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)type).add((int)sizeMS).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    PlayoutDelay
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_PlayoutDelay
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint16_t delayMS;
	jint result = (jint)pDeviceModule->PlayoutDelay(&delayMS);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)delayMS).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RecordingDelay
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_RecordingDelay
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint16_t delayMS;
	jint result = (jint)pDeviceModule->RecordingDelay(&delayMS);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)delayMS).getOutput());
	}
	return result;
}


/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    CPULoad
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_CPULoad
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint16_t load;
	jint result = (jint)pDeviceModule->CPULoad(&load);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)load).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StartRawOutputFileRecording
 * Signature: (JLjava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StartRawOutputFileRecording
  (JNIEnv * env, jclass cls, jlong p, jstring pcmFileNameUTF8)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StartRawOutputFileRecording(JniHelper::j2c_string(env, pcmFileNameUTF8).c_str());
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StopRawOutputFileRecording
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StopRawOutputFileRecording
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StopRawOutputFileRecording();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StartRawInputFileRecording
 * Signature: (JLjava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StartRawInputFileRecording
	(JNIEnv * env, jclass cls, jlong p, jstring pcmFileNameUTF8)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StartRawInputFileRecording(JniHelper::j2c_string(env, pcmFileNameUTF8).c_str());
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    StopRawInputFileRecording
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_StopRawInputFileRecording
	(JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->StopRawInputFileRecording();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetRecordingSampleRate
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetRecordingSampleRate
  (JNIEnv * env, jclass cls, jlong p, jint samplesPerSec)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetRecordingSampleRate(samplesPerSec);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    RecordingSampleRate
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_RecordingSampleRate
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t samplesPerSec;
	jint result = (jint)pDeviceModule->RecordingSampleRate(&samplesPerSec);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)samplesPerSec).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetPlayoutSampleRate
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetPlayoutSampleRate
	(JNIEnv * env, jclass cls, jlong p, jint samplesPerSec)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetPlayoutSampleRate(samplesPerSec);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    PlayoutSampleRate
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_PlayoutSampleRate
	(JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	uint32_t samplesPerSec;
	jint result = (jint)pDeviceModule->PlayoutSampleRate(&samplesPerSec);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add((int)samplesPerSec).getOutput());
	}
	return result;
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    ResetAudioDevice
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_ResetAudioDevice
  (JNIEnv * env, jclass cls, jlong p)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->ResetAudioDevice();
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    SetLoudspeakerStatus
 * Signature: (JZ)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_SetLoudspeakerStatus
  (JNIEnv * env, jclass cls, jlong p, jboolean enable)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	return (jint)pDeviceModule->SetLoudspeakerStatus(enable != 0);
}

/*
 * Class:     com_voe_AudioDeviceModule
 * Method:    GetLoudspeakerStatus
 * Signature: (JLcom/voe/common/OutputParam;)I
 */
JNIEXPORT jint JNICALL Java_com_voe_AudioDeviceModule_GetLoudspeakerStatus
  (JNIEnv * env, jclass cls, jlong p, jobject obj)
{
	webrtc::AudioDeviceModule* pDeviceModule = (webrtc::AudioDeviceModule*)p;
	bool enabled;
	jint result = (jint)pDeviceModule->GetLoudspeakerStatus(&enabled);
	if(result == 0)
	{
		JniOutputBuilder job(env);
		OutputParam param(env, obj);
		param.setArray(job.add(enabled).getOutput());
	}
	return result;
}
